package com.tanhua.controller;

import com.tanhua.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/comments")
public class CommentsController {
    @Autowired
    private CommentsService commentsService;

    /**
     * GET/comments
     * 评论列表
     */
    @GetMapping
    public ResponseEntity findComments(String movementId,Integer page,Integer pagesize){
        return commentsService.findComments(movementId,page,pagesize);
    }
    /**
     * POST/comments
     * 发表评论
     */
    @PostMapping
    public ResponseEntity submitComment(@RequestBody Map<String,String> map){
        String publishId = map.get("movementId");
        String content = map.get("comment");
        return commentsService.submitComment(publishId,content);
    }

}
